package com.yunti.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.yunti.business.domain.BaseSubItem;
import com.yunti.business.service.IBaseSubItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分数项Controller
 *
 * @author ruoyi
 * @date 2024-05-20
 */
@RestController
@RequestMapping("/scoreItem/item")
public class BaseSubItemController extends BaseController
{
    @Autowired
    private IBaseSubItemService baseSubItemService;

    /**
     * 查询分数项列表
     */
    @PreAuthorize("@ss.hasPermi('scoreItem:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(BaseSubItem baseSubItem)
    {
        startPage();
        List<BaseSubItem> list = baseSubItemService.selectBaseSubItemList(baseSubItem);
        return getDataTable(list);
    }

    /**
     * 导出分数项列表
     */
    @PreAuthorize("@ss.hasPermi('scoreItem:item:export')")
    @Log(title = "分数项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BaseSubItem baseSubItem)
    {
        List<BaseSubItem> list = baseSubItemService.selectBaseSubItemList(baseSubItem);
        ExcelUtil<BaseSubItem> util = new ExcelUtil<BaseSubItem>(BaseSubItem.class);
        util.exportExcel(response, list, "分数项数据");
    }

    /**
     * 获取分数项详细信息
     */
    @PreAuthorize("@ss.hasPermi('scoreItem:item:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(baseSubItemService.selectBaseSubItemById(id));
    }

    /**
     * 新增分数项
     */
    @PreAuthorize("@ss.hasPermi('scoreItem:item:add')")
    @Log(title = "分数项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BaseSubItem baseSubItem)
    {
        return toAjax(baseSubItemService.insertBaseSubItem(baseSubItem));
    }

    /**
     * 修改分数项
     */
    @PreAuthorize("@ss.hasPermi('scoreItem:item:edit')")
    @Log(title = "分数项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BaseSubItem baseSubItem)
    {
        return toAjax(baseSubItemService.updateBaseSubItem(baseSubItem));
    }

    /**
     * 删除分数项
     */
    @PreAuthorize("@ss.hasPermi('scoreItem:item:remove')")
    @Log(title = "分数项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(baseSubItemService.deleteBaseSubItemByIds(ids));
    }
}
